<%@ page language="java" isELIgnored="false" import="java.util.*"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%  
  response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
  response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
  response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
  response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
  String baseURL = request.getContextPath();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>预处理数据查询</title>
<link href="<%=request.getContextPath()%>/fare/css/base.css" rel="stylesheet" type="text/css" />

<link href="<%=request.getContextPath()%>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<%-- <script src="<%=request.getContextPath()%>/fare/js/show.js" type="text/javascript" ></script> --%>
<script src="<%=request.getContextPath()%>/fare/js/jquery/jquery-1.3.2.min.js" type="text/javascript" ></script>
<script src="<%=request.getContextPath()%>/fare/js/datePicker/WdatePicker.js" type="text/javascript" ></script>
<script src="<%=request.getContextPath()%>/fare/js/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/fare/lib/json2.js" type="text/javascript"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/fare/js/vtip.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/fare/js/datePicker/WdatePicker.js"></script>

<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>
<link href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css' rel="stylesheet" type="text/css" />
<link rev="stylesheet" media="all" href="<%=request.getContextPath() %>/fare/css/form_style.css" type="text/css" rel="stylesheet">
<link href="<%=request.getContextPath() %>/fare/css/vtip.css" rel="stylesheet" type="text/css" />
<!-- 圆角文本框 -->
<link href="<%=request.getContextPath() %>/fare/css/htc/htc.css" rel="stylesheet" type="text/css" />

<style type="text/css">
	.showTable td,.showTable th{
		border: 1px solid #B1CDE3;  
		font-size: 0.8em; 
        padding:3px;   
        margin:3px;  
        border-collapse:collapse; 
        text-align: center; 
	}



</style>

<script>
 function selectChange(){
	var table = $("#pretrement").val();
	if(table == 'LP_FLIGHT'){
		$("#startTime").attr("disabled",true);
		$("#flightNumber").attr("disabled",false);
	}else if(table == 'LP_LINE_HOUR'||table == 'LP_LINE_DAY'){
		$("#startTime").attr("disabled",true);
		$("#flightNumber").attr("disabled",true);		
	}else if(table == 'LP_FLIGHT_HISTORY'){
		$("#startTime").attr("disabled",false);
		$("#flightNumber").attr("disabled",false);
	}else if(table == 'LP_FLIGHT_HISTORY_FIXED_CRAWLDATE'){
		$("#startTime").attr("disabled",false);
		$("#flightNumber").attr("disabled",false);
	}
	
	
	
	
	
 }
</script>

<script type="text/javascript">
	function currentDate(){ 
	    var now = new Date();       
	    var year = now.getFullYear();
	    var month = now.getMonth() + 1;
	    var day = now.getDate();
	   
	    var today = year + "-";       
	    if(month < 10)
	        today += "0";       
	    today += month + "-";       
	    if(day < 10)
	        today += "0";           
	    today += day;       
	    return(today); 
	} 
	$(document).ready(function(){
		if($('#flightTime').val()==''){
			$('#flightTime').val(currentDate());
		}	
		if($('#startTime').val()==''){
			$('#startTime').val(currentDate());
		}
		
		
		
		$('#depCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
		$('#arrCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	});
	
	  
	var v1,v2,v3;
	var isreflush=function compareSelectValue(i,o1,o2,o3){
		  if(v1!=o1||v2!=o2||v3!=o3){
				 v1=o1;
		    	 v2=o2;
		    	 v3=o3;
				return true;
			}
				 v1=o1;
		    	 v2=o2;
		    	 v3=o3;
			return false;
	}

	var i=1;
	function loadFlightNo(){
	 	var depCity=$("#depCity").val();
	 	var arrCity=$("#arrCity").val();
	 	var carrier=$("#carrier").val();
	 	
		
		
	 	if(depCity!="中文/拼音"&&arrCity!="中文/拼音"&&carrier!=""){
	 		var bool= isreflush(i,depCity,arrCity,carrier);
	 		if(bool){
			    		$.ajax({
			                  url : 'commonAction!outCityFlightNo2.action',
			                  data : {'depCity':depCity,'arrCity':arrCity,'carrier':carrier},
			                  type : "POST",
			                  dateType:'json',
			                  beforeSend : function(XMLHttpRequest) {// 提交之前的处理代码放在此处,可空着
			                                    
			                  },
			                  success : function(data) {
			                	  document.getElementById("flightNumber").innerHTML="";
	 		                	  if(data==""||data==null){
	 		                		 $("#flightNumber").html("<option value=''>--选 择--</option>");
	 		                		  return ;
	 		                	  }
	 		                	 $("#flightNumber").html("<option value=''>--选 择--</option>");
			                	  var unitys_str=data.split("#");
			                	 	
			                	  for(var i=0;i<unitys_str.length;i++){
			                		  var s_unity=unitys_str[i];
			                		  if(s_unity!="" || s_unity!=null){
			                			  var opt=document.createElement("OPTION");
			                			  document.getElementById("flightNumber").options.add(opt);
			                			    opt.value=s_unity;
			                			    opt.text=s_unity;
			                		   }
			                	  }
			                	  document.getElementById("flightNumber").options[0].selected=true;
			                  },
			                  error : function(data) {
			                        alert('提示', '数据超时或错误,请重新提交');
			                  }
			            });
	 		}
	 	}
	 	i++;
	 }
	$("#depCity").live('click', function() {
		loadFlightNo();
	});
	$("#arrCity").live('click', function() {
		loadFlightNo();
	});
</script>

</head>

<body>
<div class="form_table_tltle">查询条件 </div>

<form id="taskRecordForm" action="pretrementQueryAction!pretrementQuery.action" method="post">
<TABLE cellspacing="0" cellpadding="0" width="100%" border="0" class="form_table">

  <TBODY>
  
     <TR class="tab">
 
    <TD width="120" class="left" style="text-align:left">预处理表：&nbsp;&nbsp;</td>
    <td>
    
  	 <select name="pretrementTable"  style="width: 150px;" id="pretrement" onchange="selectChange()">
	   <!--  <option value="" selected="selected">请选择</option> -->
		<option value="LP_FLIGHT" selected="selected">LP_FLIGHT</option>
		<option value="LP_LINE_HOUR" >LP_LINE_HOUR</option>						
		<option value="LP_LINE_DAY" >LP_LINE_DAY</option>		
		<option value="LP_FLIGHT_HISTORY" >LP_FLIGHT_HISTORY</option>		
		<option value="LP_FLIGHT_HISTORY_FIXED_CRAWLDATE" >LP_FLIGHT_HISTORY_FIXED_CRAWLDATE</option>
		<!-- <option value="LP_FLIGHT_OFFICIAL_CHANNEL_PLUS_DAY" >LP_FLIGHT_OFFICIAL_CHANNEL_PLUS_DAY</option> -->
		<!-- <option value="LP_FLIGHT_OFFICIAL_CHANNEL_PLUS_TOP5" >LP_FLIGHT_OFFICIAL_CHANNEL_PLUS_TOP5</option>	 -->	
	</select><font color="red" >*</font>
  	</TD>
   
    <td>
  	</TD>
  </TR>
  
  <TR class="tab">
    <TD width="120" class="left" style="text-align:left">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;段：</TD>
    <TD width="40%">
			
					<%-- <span>从 </span> 
							<input id='depCity' name="depCity" type='text' onclick="loadFlightNo()" value='' style="width: 102px" value="${vo.fromCity }" /> 
							<span>到</span> 
							<input id='arrCity' name="arrCity" type='text' onclick="loadFlightNo()" value='' style="width: 102px" value="${vo.toCity }"/><font color="red" >*</font>
							<span style="color: #ff0000">*</span><br /> --%>
						<jsp:include page="../inc/flightSelect.jsp">
						    <jsp:param value="${fromCity}" name="fromCity"/>
						    <jsp:param value="${fromCityCode}" name="fromCityCode"/>
						    <jsp:param value="${toCity}" name="toCity"/>
						    <jsp:param value="${toCityCode}" name="toCityCode"/>
 						</jsp:include>
						 	
						
					</TD>
					  <TD width="120" class="left" style="text-align:left">航空公司：&nbsp;&nbsp;</td>
    <td>
    
  	 <select name="carrier"  onchange="loadFlightNo()" style="width: 150px;" id="carrier">
		<option value="" selected="selected">--请选择--</option>
							<c:choose>
			<c:when test="${uggsourceList == null}">
			</c:when>
			<c:otherwise>
				<c:forEach var="item" items="${uggsourceList }">
					<option value="${item.hbaseKey}" 
					<c:if test="${item.hbaseKey==carrier}">selected='selected' 
					</c:if> >${item.name}</option>
				</c:forEach>
			</c:otherwise>
		</c:choose>
	</select><font color="red" >*</font>
  	</TD>
   
  </TR>
  
  <TR class="tab">
    <TD  width="120" class="left" style="text-align:left">抓取时间：</TD>
    <TD>
    
      <input id="startTime"  name="startTime" type="text" id="text2" style="width: 100px;"  onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})">
     <%--  <span>到</span>
      <input id="endTime" name="endTime" type="text" id="text2" style="width: 100px;"  onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH'})"><font color="red" >*</font> --%>
    </TD>
  
   
    <TD  width="120" height="26" class="left" style="text-align:left">航班日期：</TD>
    <TD>
      <input id="flightTime" name="flightTime" type="text" id="text2" style="width: 100px;"  onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"><!-- <font color="red" >*</font> -->
    
    </TD>
  </TR>
  <TR class="tab">
   <TD width="120" class="left" style="text-align:left">航&nbsp;&nbsp;&nbsp;&nbsp;班&nbsp;&nbsp;&nbsp;&nbsp;号：&nbsp;&nbsp;</td>
    <td>
  	  <select name="flightNumber" id="flightNumber"  onmouseover="loadFlightNo()" >
  <c:if test="${not empty flightNumber }">
       <option value="${flightNumber }">${flightNumber }</option></c:if>
       <c:if test="${empty flightNumber }">
	    <option value="">--选 择--</option></c:if>
	    </select>
  	</TD>
   <TD width="90" class="left" style="text-align:left">数据来源：</TD>
    <TD colspan="3">
    				<select class="easyui-combobox" name="grabChannel" style="width: 150px;" id="grabChannel">
							
							<option value="航空公司官网" selected="selected">航空公司官网</option>
							<option value="00001">淘宝旅游网</option>
							<option value="00002">去哪儿网</option>	
							<option value="00003">携程网</option>
							<option value="00004">艺龙网</option>
					</select><font color="red" >*</font>
					
					<%-- <span style="color: #ff0000">*</span> --%> 
					</TD>
  </TR>
  <TR class="tab">
    <TD colspan="4" style="text-align:center;height:35px;">
      <input type="button" name="Submit2" class="btn01" id="monitorSubmit"   style="width:80px">
    </TD>
  </TR>
</TBODY>
</TABLE>
</form>
<p></p>
<div id="maingrid" style="margin-top:20px"></div>
</body>
<script type="text/javascript">
var columns=[ 
			{  display : '序号',	width:  50, 
				render:function(item,index)
				   {return (index+1);}
		    }, 
			{display : '区域  ',width : 40,		name : 'areaName'},
			{display : '区域编号  ',width : 50,		name : 'areaCode'},
			{display : '航空公司 ',	width : 90,		name : 'carrierFullName'},
			{display : '航空公司编号 ',	width : 80,		name : 'carrierKey'},
			/* {display : '网站名称 ',width : 80,		name : 'grabChannel'}, */
			{display : '网站名称ID',width : 80,		name : 'grabChannelId'},
			{display : '数据来源编号',width :80,		name : 'grabChannelNum'},
			
			{display : '航班时间 ',width : 100,	    name : 'flightBatchDate'}, 
			{display : '航班号  ',width : 70,	name : 'flightId'},
			{display : '出发城市  ',width : 50,		name : 'fromCityName'},
			{display : '出发城市编号  ',width : 80,		name : 'fromCity'},
			{display : '到达城市 ',width : 50,		name : 'toCityName'},
			{display : '到达城市编号',width : 80,		name : 'toCity'},
			{display : '高价',width : 50,		name : 'highPrice'},
			{display : '低价',width : 50,		name : 'lowerPrice'},
			{display :'抓取时间' ,width:100,name:'grabDate',render:function(row){
				return row.grabDate.substring(0,4)+"-"+row.grabDate.substring(4,6)+"-"+row.grabDate.substring(6,8)+" "+row.grabDate.substring(8,10);
			}},
			{display : '更多',width :60 ,render:function(row){
				var returnTripLength = row.returnTrip.length;
				//alert(returnTripLength);
				var tableStr =  '<table class='+'showTable'+'>';
				if(returnTripLength && returnTripLength > 0){
					
					tableStr += '<th>航空公司</th>'+'<th>航班号</th>'+'<th>航班日期</th>'+'<th>出发机场</th>'+'<th>到达机场</th>'+'<th>出发地</th>'+'<th>目的地</th>'+'<th>往返价格</th>';
					 for(var j = 0 ; j< returnTripLength ; j++){
						if(row.returnTrip[j].fromCityName != null && row.returnTrip[j].toCityName != null){
							tableStr += '<tr>';
							tableStr += '<td>'+row.returnTrip[j].carrierName+'</td>';
						 	tableStr += '<td>'+row.returnTrip[j].flightNo+'</td>';
							tableStr += '<td>'+row.returnTrip[j].flightDate+'</td>';
							tableStr += '<td>'+row.returnTrip[j].fromAir+'</td>';
							tableStr += '<td>'+row.returnTrip[j].toAir+'</td>';
							tableStr += '<td>'+row.returnTrip[j].fromCityName+'</td>';
							tableStr += '<td>'+row.returnTrip[j].toCityName+'</td>';			
							tableStr += '<td>'+row.returnTrip[j].totalPrice+'</td>'; 
							tableStr += '</tr>';
						}
						
					
					} 
					tableStr += '</table>';
					
					
					
					
				}
				
				
				return '<a href="javascript:void(0);" class="vtip" title="'+tableStr+'">更多价格</a>';	
			}}
			
			];
			
	//查询任务
    $(function(){
	   $("#monitorSubmit").click(
		 function (){
			
			 	var flightNumber=$("#flightNumber").val();
				var depCity=$("#depCity").val();
				var arrCity=$("#arrCity").val();
				var flightTime=$("#flightTime").val();
				var grabChannel=$("#grabChannel").val();
				var carrier=$("#carrier").val();
				var startTime = $("#startTime").val();
				var endTime = $("#endTime").val();
				var pretrementTable = $("#pretrement").val();
				if(depCity==""||depCity=='中文/拼音'){
					$.ligerDialog.question('航线出发城市不能为空!');
					return ;
				}
				if(arrCity==""||arrCity=='中文/拼音'){
					$.ligerDialog.question('航线到达城市不能为空!');
					return ;
				}
				if(carrier == "") {
					$.ligerDialog.question('航空公司不能为空!');
					return ;
				}
				if(grabChannel==""){
					$.ligerDialog.question('数据来源不能为空！');
					return ;
				}
				
				/* if(flightTime==""){
					$.ligerDialog.question('航班时间不能为空!');
					return ;
				} */
				
		
			
	        var url="<%=request.getContextPath() %>/pretrementQueryAction!pretrementQuery.action"
	        +"?pretrementTable="+pretrementTable+"&&flightNumber="+flightNumber+"&&depCity="+encodeURI(encodeURI(depCity))+
	        "&&arrCity="+encodeURI(encodeURI(arrCity))+"&&grabChannel="+encodeURI(encodeURI(grabChannel))+
	        "&&flightTime="+flightTime+"&&endTime="+endTime+"&&startTime="+startTime+"&&carrier="+encodeURI(encodeURI(carrier));
			
						$("#maingrid").ligerGrid({
							    dataAction : 'server',
							    columns : columns,
							    url:url,
						        width: '100%',
						        pageSize:10,
						        usePager:true,
						        title:'查询结果',
								showTitle:true,
								height:400,
								pagesizeParmName:'pagesize'
					    	});   
			});
	 
	})
	
</script>
</html>

